
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>当出现问题时Seata的回滚机制是怎样的？ - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>当出现问题时Seata的回滚机制是怎样的？ - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">在 Seata 中，一个分布式事务由哪两个核心概念组成？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">一个 Seata 分布式事务被定义为一个全局事务（Global Transaction），它包含了多个分支事务（Branch Transaction）。每个分支事务对应一个具体的操作。</div>
          </div>
          <div class="card-source">来源: 1. 全局事务的定义与执行</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">Seata 回滚机制的核心依赖是什么？它通过记录哪两种数据镜像来实现回滚？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Seata 的回滚机制依赖于其核心组件 Undo Log（撤销日志）。它通过记录操作的“前镜像”（操作前的数据状态）和“后镜像”（操作后的数据状态）来实现回滚。</div>
          </div>
          <div class="card-source">来源: 3. Seata 的回滚机制 -> a. Undo Log 的记录</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">根据文档，触发 Seata 回滚机制的条件主要有哪些？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Seata 的回滚机制会在三种情况下触发：1. 某个分支事务执行失败；2. 全局事务超时；3. 开发者通过代码显式触发手动回滚。</div>
          </div>
          <div class="card-source">来源: 2. 回滚的触发条件</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">当全局事务需要回滚时，Seata 的分支事务是如何恢复数据的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">当分支事务收到来自 TC 的回滚请求后，它会利用 Undo Log 中记录的“前镜像”数据，将数据库状态恢复到该操作执行之前的状态。</div>
          </div>
          <div class="card-source">来源: 3. Seata 的回滚机制 -> b. 回滚过程</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">Seata 是通过哪个具体组件来自动拦截 SQL 并记录 Undo Log 的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">这个过程通过 Seata 的 DataSource Proxy 代理来实现。这个代理会拦截 SQL 语句，在操作前后记录数据快照，从而生成 Undo Log。</div>
          </div>
          <div class="card-source">来源: 3. Seata 的回滚机制 -> a. Undo Log 的记录</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">Seata 是如何保证其回滚操作的可靠性和容错性的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Seata 通过两个关键特性来保障：一是回滚操作的幂等性，即多次执行结果一致；二是设计了重试机制，确保在网络抖动或服务短暂不可用等情况下，回滚操作能够最终完成。</div>
          </div>
          <div class="card-source">来源: 4. 一致性和可靠性保障</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
